package com.power.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * ClassName:PrimaryMongoConfig
 * Package:com.abrs.config
 * Description:
 *
 * @date:2019/12/17 17:22
 * @author:zhangqiang
 */
@Configuration
public class PrimaryMongoConfig extends AbstractMongoConfig {

    @Value("${spring.data.mongodb.primary.uri}")
    private String uri;

    @Primary
    @Bean(name = "primaryMongoTemplate")
    @Override
    public MongoTemplate getMongoTemplate() throws Exception {
        return new MongoTemplate(mongoDbFactory(uri));
    }
}

